/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Admin_EditOrder.java
 *
 * Created on Mar 31, 2011, 12:05:31 AM
 */
package admin_gui;

import admin.Controller.OrderController;
import java.util.Vector;

/**
 *
 * @author edaype
 */
public class Admin_EditOrder extends javax.swing.JPanel {

    private OrderController orderController;
    private Vector edit_vect;

    /** Creates new form Admin_EditOrder */
    public Admin_EditOrder() {
        initComponents();
    }

    public Admin_EditOrder(OrderController aThis, Vector vector) {
        this.orderController = aThis;
        initComponents();
        edit_vect = (Vector) (vector.get(0));
        IDField.setText((String) edit_vect.get(0).toString());
        DateField.setText((String) edit_vect.get(1));
        StatusCombo.setSelectedItem(edit_vect.get(2).toString());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        ItemPanel = new javax.swing.JPanel();
        IDLabel = new javax.swing.JLabel();
        DateLabel = new javax.swing.JLabel();
        StatusLabel = new javax.swing.JLabel();
        IDField = new javax.swing.JTextField();
        DateField = new javax.swing.JTextField();
        StatusCombo = new javax.swing.JComboBox();
        ButtonPanel = new javax.swing.JPanel();
        SubmitButton = new javax.swing.JButton();
        EditLabel = new javax.swing.JLabel();
        SubmitButton1 = new javax.swing.JButton();
        Back = new javax.swing.JButton();

        setBackground(new java.awt.Color(255, 255, 255));

        ItemPanel.setBackground(new java.awt.Color(255, 255, 255));

        IDLabel.setFont(new java.awt.Font("Tahoma", 0, 24));
        IDLabel.setText("Order ID");

        DateLabel.setFont(new java.awt.Font("Tahoma", 0, 24));
        DateLabel.setText("Order Date");

        StatusLabel.setFont(new java.awt.Font("Tahoma", 0, 24));
        StatusLabel.setText("Order Status");

        IDField.setEditable(false);
        IDField.setFont(new java.awt.Font("Tahoma", 0, 24));

        DateField.setEditable(false);
        DateField.setFont(new java.awt.Font("Tahoma", 0, 24));

        StatusCombo.setFont(new java.awt.Font("Tahoma", 0, 24));
        StatusCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Paid", "Shipped", "Cancelled" }));

        javax.swing.GroupLayout ItemPanelLayout = new javax.swing.GroupLayout(ItemPanel);
        ItemPanel.setLayout(ItemPanelLayout);
        ItemPanelLayout.setHorizontalGroup(
            ItemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ItemPanelLayout.createSequentialGroup()
                .addGroup(ItemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ItemPanelLayout.createSequentialGroup()
                        .addGap(75, 75, 75)
                        .addComponent(IDLabel)
                        .addGap(18, 18, 18)
                        .addComponent(IDField, javax.swing.GroupLayout.PREFERRED_SIZE, 285, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(ItemPanelLayout.createSequentialGroup()
                        .addGap(34, 34, 34)
                        .addComponent(StatusLabel)
                        .addGap(18, 18, 18)
                        .addComponent(StatusCombo, 0, 285, Short.MAX_VALUE))
                    .addGroup(ItemPanelLayout.createSequentialGroup()
                        .addGap(50, 50, 50)
                        .addComponent(DateLabel)
                        .addGap(18, 18, 18)
                        .addComponent(DateField, javax.swing.GroupLayout.DEFAULT_SIZE, 285, Short.MAX_VALUE)))
                .addContainerGap())
        );
        ItemPanelLayout.setVerticalGroup(
            ItemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ItemPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(ItemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(IDLabel)
                    .addComponent(IDField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(73, 73, 73)
                .addGroup(ItemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(DateField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(DateLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 77, Short.MAX_VALUE)
                .addGroup(ItemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(StatusCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(StatusLabel))
                .addGap(70, 70, 70))
        );

        ButtonPanel.setBackground(new java.awt.Color(255, 255, 255));

        SubmitButton.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        SubmitButton.setText("Submit");
        SubmitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SubmitButtonActionPerformed(evt);
            }
        });

        EditLabel.setFont(new java.awt.Font("Copperplate Gothic Bold", 2, 48)); // NOI18N
        EditLabel.setText("Edit Order");

        SubmitButton1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        SubmitButton1.setText("Reset");
        SubmitButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SubmitButton1ActionPerformed(evt);
            }
        });

        Back.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        Back.setText("<Back");
        Back.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BackActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout ButtonPanelLayout = new javax.swing.GroupLayout(ButtonPanel);
        ButtonPanel.setLayout(ButtonPanelLayout);
        ButtonPanelLayout.setHorizontalGroup(
            ButtonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ButtonPanelLayout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(EditLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 317, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(32, 32, 32)
                .addComponent(SubmitButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(28, 28, 28)
                .addComponent(SubmitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26)
                .addComponent(Back, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(29, Short.MAX_VALUE))
        );
        ButtonPanelLayout.setVerticalGroup(
            ButtonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ButtonPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(ButtonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(EditLabel)
                    .addComponent(SubmitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(SubmitButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Back, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(12, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(ButtonPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(135, 135, 135)
                        .addComponent(ItemPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(110, 110, 110)
                .addComponent(ItemPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 154, Short.MAX_VALUE)
                .addComponent(ButtonPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void SubmitButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SubmitButton1ActionPerformed
        // TODO add your handling code here:
        StatusCombo.setSelectedItem(edit_vect.get(2).toString());
    }//GEN-LAST:event_SubmitButton1ActionPerformed

    private void SubmitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SubmitButtonActionPerformed

        String status = StatusCombo.getSelectedItem().toString();
        String ID = IDField.getText();
        int id = Integer.parseInt(ID);
        orderController.updateOrderstatus(id, status);
    }//GEN-LAST:event_SubmitButtonActionPerformed

    private void BackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BackActionPerformed
        orderController.goBackSerachOrderPane();
    }//GEN-LAST:event_BackActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Back;
    private javax.swing.JPanel ButtonPanel;
    private javax.swing.JTextField DateField;
    private javax.swing.JLabel DateLabel;
    private javax.swing.JLabel EditLabel;
    private javax.swing.JTextField IDField;
    private javax.swing.JLabel IDLabel;
    private javax.swing.JPanel ItemPanel;
    private javax.swing.JComboBox StatusCombo;
    private javax.swing.JLabel StatusLabel;
    private javax.swing.JButton SubmitButton;
    private javax.swing.JButton SubmitButton1;
    // End of variables declaration//GEN-END:variables
}
